<?php $this->headScript()->appendFile(HTTP_HOST.'/js/site-admin/regions.js'); ?>
<?php $this->headScript()->captureStart();?>

<?php  $this->headScript()->captureEnd();?>
<a href="<?=$this->url(array('action' => 'edit', 'addnew' => 1))?>"><?=$this->translate('Добавить регион')?></a><br />
<form method="get" action="<?=HTTP_HOST?>/site-admin/region/index?country=<?=$this->country?>">
	<?=$this->translate('Страна')?>: <?=$this->formSelect('country', $this->country, array('onchange' => 'this.form.submit();'), $this->countries);?>
</form>
<br />
<?php if (sizeof($this->regions) > 0 || sizeof($this->CountryPage) > 0) { ?>
<?php $i = 1;?>
<table id="cat_table">
	<tr class="head" style="background: url('<?=HTTP_HOST; ?>/images/controll/table_header.png');">
		<td class="checkbox_td"></td>
		<td><?=$this->translate('Код')?></td>
		<td></td>
		<td><?=$this->translate('Регион')?></td>
		<td>-</td>
		<td><?=$this->translate('Сортировка')?></td>
		<td colspan="2" class="right_angle"></td>
	</tr>
	<tr id="subhead">
		<td class="checkbox_td"><input type="checkbox" class="enable_all"></td>
		<td class="_table_code"><input type="text" name="code" id="code_field" maxlength="10"/></td>
		<td>-</td>
		<td><input type="text" name="search_region" id="search_region" maxlength="255"/></td>
		<td class="active_td">-</td>
		<td class="_table_sort_td">-</td>
		<td colspan="2" class="search_image"><img src="<?=HTTP_HOST; ?>/images/controll/zoom.png" alt="" class="zoom_icon"/></td>
	</tr>	
	<?php foreach ($this->regions as $k => $v) { $i++;?>
		<tr class="cl" <?=(!is_int($i/2))?"style='background: #e1e0e0;'":""; ?>>
			<td class="checkbox_td"><input type="checkbox" name="<?=$v['ID']?>" class="region_ch"></td><!--  -->
			<td class="_table_code"><?=$v['ID']?></td>
			<?php $id = $v['ID']; ?>
			<td class="type_td"><img src="<?=HTTP_HOST; ?>/images/controll/folder.png" alt="" class="object_type" id="state-<?=$v['ID']?>"/></td>
			<td class="_table_title"><a href="<?=$this->url(array('controller' => 'city', 'action' => 'index', 'region'=>$v['ID']))?>"><?=$v['Name']?></a></td>
			<td class="active_td"><img src="<?=HTTP_HOST; ?>/images/controll/<?=$v['active'] == 0 ? 'inactive.png' : 'active.png'?>" alt="" class="state" id="state-<?=$v['ID']?>" title="<?=$v['active'] == 0 ? $this->translate('Не активный') : $this->translate('Активный')?>"/></td>
			<td class="_table_sort_td"><input type="text" class="sort_field" name="sort" value="<?=$v['sort']?>"></td>
			<td class="edit_td"><a href="<?=$this->url(array('controller' => 'region', 'action' => 'edit', 'id' => $k), null, false)?>"><img src="<?=HTTP_HOST; ?>/images/controll/edit.png" alt="" class="ed-del-btn" title="<?=$this->translate('Редактировать регион')?>"/></a></td>
			<td class="del_td"><div id="<?=$v['ID']?>" class="del_ot" rel="<?=$v['Name']?>" ><img src="<?=HTTP_HOST; ?>/images/controll/delete.png" alt=""  class="ed-del-btn" title="<?=$this->translate('Удалить регион')?>"/></div></td>
		</tr>
	<?php } ?>
	
	<?php foreach ($this->CountryPage as $k => $v) { $i++;?>
		<tr class="cl" <?=(!is_int(($i)/2))?"style='background: #e1e0e0;'":""; ?>>
			<td class="checkbox_td"><input type="checkbox" name="<?=$v['ID']?>" class="c_page_ch"></td>
			<td class="_table_code"><?=$v['ID']?></td>
			<?php $id = $v['ID']; ?>
			<td class="type_td"><img src="<?=HTTP_HOST; ?>/images/controll/file.png" alt="" class="object_type" id="state-<?=$v['ID']?>"/></td>
			<td class="_table_title"><?=$v['Title']?></td>
			<td class="active_td"><img src="<?=HTTP_HOST; ?>/images/controll/<?=((int)$v['active'] == 0)?'inactive.png':'active.png'?>" alt="" class="page_state" id="state-<?=$v['ID']?>"/></td>
			<td class="_table_sort_td"><input type="text" name="sort" class="sort_field" value="<?=$v['Order']?>"></td>
			<td class="edit_td"><a href="<?=$this->url(array('controller'=>'country-page','action' => 'edit', 'id' => $k))?>"><img src="<?=HTTP_HOST; ?>/images/controll/edit.png" alt="" class="ed-del-btn" title="<?=$this->translate('Редактировать страницу')?>"/></a></td>
			<td class="del_td"><div id="<?=$v['ID']?>" class="del_cp" rel="<?=$v['Title']?>" ><img src="<?=HTTP_HOST; ?>/images/controll/delete.png" alt=""  class="ed-del-btn" title="<?=$this->translate('Удалить страницу')?>"/></div></td>
		</tr>
	<?php } ?>	
	<tr class="table_footer cl">
		<td id="ch" class="checkbox_td"><input type="checkbox" class="enable_all"></td>
		<td colspan="7" id="footer_ico"><div id="group_delete"><img src="<?=HTTP_HOST; ?>/images/controll/delete.png" alt=""  class="ed-del-btn"/><div id="delete_label"><?=$this->translate('Удалить')?></div></div>
			<div id="_add_new_object_div">
				<a href="<?=$this->url(array('controller' => 'region', 'action' => 'edit', 'addnew' => 1))?>">
					<img src="<?=HTTP_HOST;?>/images/admin-side/add.png" alt="" class="add_sign"/>
					<?=$this->translate('Добавить регион')?>
				</a>
			</div>			
			<div id="_add_new_object_div">
				<img src="<?=HTTP_HOST;?>/images/admin-side/add.png" alt="" class="add_sign"/>
				<a href="<?=$this->url(array('controller' => 'region-page', 'action' => 'edit', 'addnew' => 1))?>">
					<?=$this->translate('Добавить странцу')?>
				</a>
			</div>
		</td>
	</tr>
</table>
<?php } else {?>
	<div id="_add_new_object_div">
		<a href="<?=$this->url(array('controller' => 'region', 'action' => 'edit', 'addnew' => 1))?>">
			<img src="<?=HTTP_HOST;?>/images/admin-side/add.png" alt="" class="add_sign"/>
			<?=$this->translate('Добавить регион')?>
		</a>
	</div>
<?php }?>